// /*
//  * @Author: WanYiMing
//  * @Date:2024-05-31-10:40
//  * @Description:
//  */

using Code.GameLogic.BaseClass;
using Code.GameLogic.XianJian.Element;
using Code.GameLogic.XianJian.UI;
using Code.GameLogic.XianJian.XianJianBehavior;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Serialization;

namespace Code.GameLogic.XianJian.Controller
{
    public class XianJianController : AbsGameLogicController<XianJianBo, XianJianManager>
    {
        public XianJianSpaceController xianJianSpaceController;

        private GameObject _xianJianSpace;

        private XianJianBehaviorController _xianJianBehaviorController;
        private XianJianFms _xianJianFms;
        
        
        public GameObject lockBox;
        public JianQiController jianQiController;
        
        
        public override void InitGo(XianJianBo xianJianBo)
        {
            SpriteRenderer spriteRenderer = this.AddComponent<SpriteRenderer>();
            spriteRenderer.sprite = Resources.Load<Sprite>("防御塔/" + xianJianBo.BaseDescription.TypeName);
            spriteRenderer.sortingOrder = 4;
            transform.localScale = new Vector3(0.3f, 0.3f, 1);
            
            //添加范围指示器
            _xianJianSpace = new GameObject("范围指示器");
            xianJianSpaceController = _xianJianSpace.AddComponent<XianJianSpaceController>();
            xianJianSpaceController.BindComponent(this);

            
            //添加防御塔行为
            // _XianJianBehaviorController = this.AddComponent<XianJianBehaviorController>();
            // _XianJianBehaviorController.LoadBehavior(xianJianBo.XianJianBehaviorList,this);
            _xianJianFms = this.AddComponent<XianJianFms>();
            
        }


        private void Update()
        {
            IsWatch();
        }

        public override void Watch()
        {
            xianJianSpaceController.MouseShow(true);
        }

        public override void Ignore()
        {
            xianJianSpaceController.MouseShow(false);
        }



        public void InView(GameObject tTigerBox)
        {
            _xianJianBehaviorController.InView(tTigerBox);
        }

        public void OutView(GameObject tTigerBox)
        {
            _xianJianBehaviorController.OutView(tTigerBox);
        }


    }
}